package cn.org.xwb.bookmall.admin.utils;

import cn.hutool.core.convert.Convert;
import cn.org.xwb.bookmall.admin.vo.UpdateAuthorityVo;
import cn.org.xwb.bookmall.admin.vo.UploadProductVo;
import cn.org.xwb.bookmall.model.po.Authority;
import cn.org.xwb.bookmall.model.po.Product;
import cn.org.xwb.bookmall.model.po.ProductCategory;
import cn.org.xwb.bookmall.model.vo.ProductCategoryVo;
import cn.org.xwb.bookmall.model.vo.ProductVo;

public class Convert2PoUtil {

    public static Authority genAuthority(UpdateAuthorityVo updateAuthorityVo) {
        return Convert.convert(Authority.class, updateAuthorityVo);
    }

    public static ProductCategory genProductCategory(ProductCategoryVo productCategoryVo) {
        return Convert.convert(ProductCategory.class, productCategoryVo);
    }

    public static Product genProduct(UploadProductVo uploadProductVo) {
        Product product = Convert.convert(Product.class, uploadProductVo);
        product.setSale(0);
        return product;
    }

    public static Product genProduct(ProductVo productVo) {
        return Convert.convert(Product.class, productVo);
    }

    public static Product genProduct(Long productId) {
        Product product = new Product();
        product.setId(productId);
        product.setIsRemove(true);
        return product;
    }

}
